﻿<RadioButton
  x:Name="TabButton"
  x:Class="uhul.Controls.TabBtn"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  d:DesignHeight="25" d:DesignWidth="200"
  MaxWidth="200"
  MinHeight="25"
  MinWidth="20"
  MouseEnter="mouseEnter"
  MouseLeave="mouseLeave"
>
  <!--xmlns:local="clr-namespace:uhul.Controls" x:Class="uhul.Controls.TabBtn"-->
  <RadioButton.Resources>

    <!--
    style for close button (currently not used)
    -->
    <Style x:Key="CloseButtonStyle" TargetType="Button">
      <Setter Property="Background" Value="#FFf0f0f0"/>
      <Setter Property="Foreground" Value="#FF000000"/>
      <Setter Property="BorderThickness" Value="0"/>

      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="Button">

            <Grid>
              <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">

                  <VisualState x:Name="Normal"/>

                  <VisualState x:Name="MouseOver">
                    <Storyboard>
                      <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                      <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="ForegroundAnimation"/>
                      <ColorAnimation Duration="0" To="#FFf0f0f0" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ForegroundAnimation"/>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Pressed">
                    <Storyboard>
                      <ColorAnimation Duration="0" To="#FF300000" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="BackgroundAnimation"/>
                      <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                      <ColorAnimation Duration="0" To="#FFf0f0f0" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ForegroundAnimation"/>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Disabled"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusStates">
                  <VisualState x:Name="Focused"/>
                  <VisualState x:Name="Unfocused"/>
                </VisualStateGroup>
              </VisualStateManager.VisualStateGroups>

              <Grid x:Name="CloseBtn" Margin="0">

                <Rectangle Opacity="0" Margin="2" Fill="#FFFFffff"/>

                <Ellipse Margin="0"
									x:Name="BackgroundAnimation"
									Fill="#FF900000" IsHitTestVisible="false"
									Opacity="0"
									Stroke="#FFc0a0a0" StrokeThickness="0.6"
								/>

                <Path
                  x:Name="ForegroundAnimation"
                  IsHitTestVisible="false"
									Data="M98,136 L47,186 L84,224 L136,173 L187,224 L225,187 L174,135 L223,85 L186,47 L136,98 L84,48 L47,85 z"
									Fill="#ff909090" 
									Stretch="Fill" Stroke="#FFFB9C9C"
									StrokeThickness="0" UseLayoutRounding="False" RenderTransformOrigin="0.5,0.5">
                  <Path.RenderTransform>
                    <CompositeTransform ScaleX="0.55" ScaleY="0.55"/>
                  </Path.RenderTransform>
                </Path>
              </Grid>

              <!--<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>-->

            </Grid>

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>




    <!--
      style1 for close button (currently used)
    -->
    <Style x:Key="CloseButtonStyle1" TargetType="Button">
      <Setter Property="Background" Value="#FFf0f0f0"/>
      <Setter Property="Foreground" Value="#FF000000"/>
      <Setter Property="BorderThickness" Value="0"/>
      
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="Button">

            <Grid>
              <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">

                  <VisualState x:Name="Normal"/>

                  <VisualState x:Name="MouseOver">
                    <Storyboard>
                      <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                      <!--<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="StrokeThickness" Storyboard.TargetName="ForegroundAnimation"/>-->
                      <ColorAnimation Duration="0" To="White" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="ForegroundAnimation" d:IsOptimized="True"/>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Pressed">
                    <Storyboard>
                    	
                      <ColorAnimation Duration="0" To="#FF300000" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="BackgroundAnimation"/>
											<!--<ColorAnimation Duration="0" To="#FF300000" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="BackgroundAnimation"/>-->
                      <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundAnimation"/>
                      <ColorAnimation Duration="0" To="White" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="ForegroundAnimation" d:IsOptimized="True"/>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Disabled"/>
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusStates">
                  <VisualState x:Name="Focused"/>
                  <VisualState x:Name="Unfocused"/>
                </VisualStateGroup>
              </VisualStateManager.VisualStateGroups>

              <Grid x:Name="CloseBtn" Margin="0">

                <!--<Rectangle Opacity="0" Margin="2" Fill="#FFFFffff"/>-->

                <Border Margin="0"
									x:Name="BackgroundAnimation"
									Background="#FFff4040" 
									Opacity="0"
								/>

                <Path 
                  x:Name="ForegroundAnimation"
									Data="M8,18 L18,8 M8,8 L18,18" Margin="8"
									Stretch="Fill" Stroke="#ff909090"
									StrokeThickness="3" UseLayoutRounding="False"
									StrokeStartLineCap="Round" StrokeEndLineCap="Round"
								/>
              </Grid>

              <!--<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>-->

            </Grid>

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>



    <!--
		style for app tab button
		-->
    <Style x:Key="TabButtonStyle" TargetType="RadioButton">
      <Setter Property="Background" Value="#FFff0000"/>
			<Setter Property="Content" Value="TabButton"/>
      <Setter Property="Foreground" Value="#FFf0f0f0"/>
      <Setter Property="Padding" Value="5"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="RadioButton">

            <Grid>
              <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">

                  <VisualState x:Name="Normal"/>

                  <VisualState x:Name="MouseOver">
                    <Storyboard>
                      <DoubleAnimation
											Duration="0" To=".25"
											Storyboard.TargetProperty="Opacity"
											Storyboard.TargetName="FgAnimation"
											/>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Pressed">
                    <Storyboard>
                  		<DoubleAnimation
                  			Storyboard.TargetName="FgAnimation"
                  			Duration="0" To=".5"
                  			Storyboard.TargetProperty="Opacity"
										/>
                  		<ColorAnimation 
                  			Storyboard.TargetName="FgAnimation"
                  			Duration="0" To="#FF404040"
                  			Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                  			d:IsOptimized="True"
											/>
                  	</Storyboard>
                  </VisualState>
                  <VisualState x:Name="Disabled">
                  	<Storyboard>
                  	<DoubleAnimation
											Storyboard.TargetName="BorderDisabled"
											Duration="0" To=".6"
											Storyboard.TargetProperty="Opacity"
										/>
										</Storyboard>
									</VisualState>

                </VisualStateGroup>
                
                <VisualStateGroup x:Name="FocusStates">
                  
                  <VisualState x:Name="Focused"/>
                  
                  <VisualState x:Name="Unfocused"/>

                </VisualStateGroup>
                
                <VisualStateGroup x:Name="CheckStates">
                  
                	<VisualState x:Name="Checked">
                		<Storyboard>
                			<ColorAnimation
                				Duration="0" To="#fff0f0f0"
                				Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
                				Storyboard.TargetName="ChkAnimation"
											/>
                			<DoubleAnimation
                				Storyboard.TargetName="ChkAnimation"
                				Duration="0" To="1"
                				Storyboard.TargetProperty="Opacity"
										  />
                			<ColorAnimation 
                				Storyboard.TargetName="contentControl"
                				Duration="0" To="Black"
                				Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                				d:IsOptimized="True"
											/>
                		</Storyboard>
                	</VisualState>
                  
                	<VisualState x:Name="Unchecked">
                		<Storyboard>
                			<ColorAnimation
                				Storyboard.TargetName="ChkAnimation"
                				Duration="0" To="#60303030"
                				Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
											/>
                			<ColorAnimation 
                				Storyboard.TargetName="contentControl"
                				Duration="0" To="{TemplateBinding Foreground}"
                				Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                				d:IsOptimized="True"
											/>
                		</Storyboard>
                	</VisualState>
                  
                	<VisualState x:Name="Indeterminate"/>
                  
                </VisualStateGroup>
                
              </VisualStateManager.VisualStateGroups>

            	<Grid x:Name="TabBtn" Margin="0,0,2,0">
                
                <Border x:Name="BgAnimation"
                  Margin="0"
                  Background="{TemplateBinding Background}"
									IsHitTestVisible="False"
                  Opacity=".7"
                />
								
                <Border x:Name="ChkAnimation" Opacity=".5"
                  Margin="0"
                  Background="#ff303030"
                />
								
                <!--CornerRadius="10,10,0,0" BorderBrush="#FF818181" BorderThickness="1"-->
                <ContentControl x:Name="contentControl"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  Content="{TemplateBinding Content}"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  Margin="8,0,25,0"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                  Foreground="{TemplateBinding Foreground}"
									FontFamily="/XapExplorer;component/Fonts/Fonts.zip#Segoe UI Light" FontSize="13"
                />
								
								<Border x:Name="FgAnimation" Opacity="0"
                  Margin="0"
                  Background="#fff0f0f0"
                />
								
                <!--tab close button-->
                <Button x:Name="closeBtn" Content="CloseBtn" Click="AppCloseClick"
                  HorizontalAlignment="Right" Width="26" Height="26" Margin="0">
                  <Button.Style>
                    <StaticResource ResourceKey="CloseButtonStyle1"/>
                  </Button.Style>
                </Button>
								
								<Border x:Name="BorderDisabled"
                  Margin="0"
                  Background="White"
									Opacity="0"
									IsHitTestVisible="False"
                />
								
								<Border x:Name="BorderFocused"
                  Margin="0"
									BorderBrush="#ff30ff30"
									Opacity="0"
									BorderThickness="0,2,0,0"
                />
            	</Grid>

            </Grid>

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>


    <Storyboard x:Key="stretchWidth">
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TabButton" Storyboard.TargetProperty="(FrameworkElement.Width)">
          <SplineDoubleKeyFrame KeyTime="0:0:0" Value="50"/>
          <SplineDoubleKeyFrame KeyTime="0:0:0.1" Value="200"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

  </RadioButton.Resources>

  <RadioButton.Style>
    <StaticResource ResourceKey="TabButtonStyle"/>
  </RadioButton.Style>
							
</RadioButton>
